package com.guigu.abo.controllers.admin;

import com.guigu.abo.pojo.ReSpeciality;
import com.guigu.abo.pojo.ReUserinfo;
import com.guigu.abo.service.ReSpecialityService;
import com.guigu.abo.service.ReUserinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@Controller
public class adminUserInfoCons {

    @Autowired
    ReUserinfoService reUserinfoService;
    @Autowired
    ReSpecialityService reSpecialityService;

    /*查询数据库的个人信息*/
    @ResponseBody
    @GetMapping("/showUserInfo")
    public ReUserinfo show(){
        ReUserinfo reUserinfo = reUserinfoService.selectAll();
        return reUserinfo;
    }
    /*修改数据库的个人信息*/
    @PostMapping("/saveOk")
    public String save(ReUserinfo reUserinfo){
        reUserinfoService.updateByPrimaryKeySelective(reUserinfo);
        return "redirect:/Home";
    }
    /*返回到首页*/
    @GetMapping("/Home")
    public String go2(){
        return "adminjsp/adminIndex";
    }
    /*删除技能信息*/
    @GetMapping("/deleteSp")
    public String dele(int id){
        reSpecialityService.deleteByPrimaryKey(id);
        return "redirect:/GoInfo";
    }
    /*修改技能信息*/
    /*1、查询数据转发到页面*/
    @GetMapping("/showSp")
    public String show(int id, Model model){
        ReSpeciality reSpeciality = reSpecialityService.selectByPrimaryKey(id);
        model.addAttribute("reSpeciality",reSpeciality);
        return "adminjsp/showSpecialityById";
    }
    /*2、修改保存  */
    @GetMapping("/saveSpOk")
    public String save(ReSpeciality reSpeciality){
        reSpecialityService.updateByPrimaryKeySelective(reSpeciality);
        return "redirect:/GoInfo";
    }






}
